<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<script>
    var date = new Date,
        hour = date.getHours(),
        minute = date.getMinutes(),
        second = date.getSeconds(),
        year = date.getFullYear(),
        month = date.getMonth() + 1,
        date1 = date.getDate(),
        day = date.getDay(), //星期值 0~6,0对应星期天,以此类推
        arr = ['星期天', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];

    console.log(hour, minute, second, year, month, date1, day, date);
    console.log(`现在时间是${year}年${month}月${date1}日  ${hour}:${minute}:${second} ${arr[day]}`);
    //例如到中午10点的倒计时
    var eventStartTime = 7;
    if (hour >= eventStartTime) {
        // var hourCount = 0,
        //     minuteCount = 0,
        //     secondCount = 0;
        console.log('活动已经开始');
    } else {
        var hourCount = eventStartTime - hour,
            minuteCount = minute && 60 - minute,
            secondCount = second && 60 - second;
        console.log(
            `距离活动开始还剩${(hourCount + '').padStart(2,'0')}:${(minuteCount+'').padStart(2,'0')}:${(secondCount+'').padStart(2,'0')}`
        );
    }
    //console.log(`距离活动开始还剩${(hourCount + '').padStart(2,'0')}:${(minuteCount+'').padStart(2,'0')}:${(secondCount+'').padStart(2,'0')}`);
    //一会好好在看看时间戳的几种用法,特别是最常用方法
</script>

<body>

</body>

</html>